<?php
/**
 * Created by PhpStorm.
 * User: xiaoxin
 * Date: 2018/10/19 0019
 * Time: 20:46
 */

namespace app\index\controller;
use think\Controller;
use app\index\model\User;

class Login extends Controller
{
	/**
	 * 登陆页面主页
	 * @return mixed
	 */
	public function index()
	{
		return $this->fetch();
	}

	/**
	 * 检测登陆是否有该用户
	 * @throws \think\db\exception\DataNotFoundException
	 * @throws \think\db\exception\ModelNotFoundException
	 * @throws \think\exception\DbException
	 */
	public function checklogin()
	{
		$post = input('post.');
		$post['password'] = md5($post['password']);
		$find = User::where(['phone'=>$post['phone'],'password'=>$post['password']])->find();
		if ($find){
			session('username',$find->username);
			session('uid',$find->uid);
			session('phone',$find->phone);
			session('face',$find->face);
			$this->success('登陆成功');
		}else{
			$this->error('对不起，没有找到该用户');
		}

	}

	/**
	 * 退出登陆
	 */
	public function loginOut(){
		session(null);
		header("Location:".url('index/login/index'));
	}

	/**
	 * 域名已经没有了
	 */
	public function qqLogin(){

	}

}